package com.meituan.dao;

import com.meituan.pojo.entity.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PermissionRepository extends JpaRepository<Permission,Integer> {
    @Query(value = "select pid from role_permission where rid=?1",nativeQuery = true)
    List<Integer> selectPidByRid(Integer rid);
    @Query(value = "select p.permission_name from user u,user_role ur,role r,role_permission rp,permission p where u.id=ur.uid and ur.rid=r.rid and r.rid=rp.rid and rp.pid=p.pid and u.user_name=?1",nativeQuery = true)
    List<String> selectPerNameByUsername(String username);
}
